package com.base.hong.utils


/**
 * @ClassName SPUtils
 * @Author Hong
 * @Date 2022/3/2 17:12
 * @Version 1.0
 */
object SPUtils {
    private const val BASE_URL_DOMAIN = "BASE_URL_DOMAIN"

    private const val TOKEN = "token"
    private const val USER_NAME = "username"//用户名

    private const val IS_FIRST_LOGIN = "is_first_login" //是否第一次登录进入首页

    fun getFirstLogin(): Int? {
        return MMKVUtils.getInt(IS_FIRST_LOGIN)
    }

    fun setFirstLogin(type: Int) {
        MMKVUtils.put(IS_FIRST_LOGIN, type)
    }

    fun setBaseUrlDoMain(type: String) {
        MMKVUtils.put(BASE_URL_DOMAIN, type)
    }

    fun getBaseUrlDoMain(): String? {
        return MMKVUtils.getString(BASE_URL_DOMAIN)
    }


    fun setToken(token: String) {
        MMKVUtils.put(TOKEN, token)
    }

    fun getToken(): String? {
        return MMKVUtils.getString(TOKEN)
    }

    fun setUserName(username: String) {
        MMKVUtils.put(USER_NAME, username)
    }

    fun getUserName(): String? {
        return MMKVUtils.getString(USER_NAME)
    }

    fun clean() {
        MMKVUtils.put(TOKEN, "")
        MMKVUtils.put(USER_NAME, "")
    }
}